package cn.zxf.note.user.question;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import jakarta.transaction.Transactional;

/**
 * Created by zengxf on 2020/3/25.
 */
@Component
public class UserQuestionSupport {

    @Autowired
    private UserQuestionRepository repos;

    public UserQuestion findOne(Integer userId) {
        return repos.findByUserId(userId);
    }

    @Transactional
    public void save(Integer userId, String qa1, String qa2, String qa3) {
        UserQuestion up = new UserQuestion()
                .setUserId(userId)
                .setQa1(qa1)
                .setQa2(qa2)
                .setQa3(qa3);
        repos.save(up);
    }

}
